Operation has No Effect (ONE)

Description:

ONE detects arithmetic expressions that always return one of their operands' value. This message is produced only for expressions that have at least one operand which is not a compile-time constant. The examined operations are described below.

Incorrect:

class MenuItem {
    private String name;
    private int index;
	
    Item(String n, int index) {
        this.name = name;
        this.index = index;
    }
	
    int getPosition() {
        int bases = 0;
        return index + bases;
    }
}

Correct:

class MenuItem {
    private String name;
    private int index;
	
    Item(String name, int index) {
        this.name = name;
        this.index = index;
    }
	
    int getPosition() {
        return index;
    }
}